class Solution:
    def intToRoman(self, num: int) -> str:
        SYM1    =   'I'	    
        SYM5    =   'V'	     
        SYM10   =   'X'	        
        SYM50   =   'L'	
        SYM100  =   'C'	
        SYM500  =   'D'	
        SYM1000 =    'M'
        SYM4    =   "IV"
        SYM9    =   "IX"
        SYM40   =   "XL"
        SYM90   =   "XC"
        SYM400  =   "CD"
        SYM900  =   "CM"

        buf = []


        cur = num//1000
        num = num%1000
        for _ in range(cur):
            buf.append(SYM1000)

        cur = num//100
        num = num%100
        if cur < 4:
            for _ in range(cur):
                buf.append(SYM100)
        elif cur == 4:
            buf.append(SYM400[0])
            buf.append(SYM400[1])
        elif cur < 9:
            buf.append(SYM500)
            for _ in range(5, cur):
                buf.append(SYM100)
        elif cur == 9:
            buf.append(SYM900[0])
            buf.append(SYM900[1])

        cur = num//10
        num = num%10
        if cur < 4:
            for _ in range(cur):
                buf.append(SYM10)
        elif cur == 4:
            buf.append(SYM40[0])
            buf.append(SYM40[1])
        elif cur < 9:
            buf.append(SYM50)
            for _ in range(5, cur):
                buf.append(SYM10)
        elif cur == 9:
            buf.append(SYM90[0])
            buf.append(SYM90[1])
        cur = num
        if cur < 4:
            for _ in range(cur):
                buf.append(SYM1)
        elif cur == 4:
            buf.append(SYM4[0])
            buf.append(SYM4[1])
        elif cur < 9:
            buf.append(SYM5)
            for _ in range(5, cur):
                buf.append(SYM1)
        elif cur == 9:
            buf.append(SYM9[0])
            buf.append(SYM9[1])

        return ''.join(buf)



if __name__ == "__main__":
    print("整数转罗马数字 py")
    test = {
  10 : "", 3 : "", 4 : "", 58 : "", 1994 : ""
    }

    for k, v in test.items():
        r = Solution().intToRoman(k)
        print(k, v, r)